<template>
    <!-- 绑定变量状态 -->
    <el-dialog v-model="store.state.homeview.dialogFromVisible" title="编辑信息">
      <el-form :model="store.state.homeview.editForm">
          <el-form-item label="编号" :label-width="formLabelWidth">
              <el-input v-model="store.state.homeview.editForm.id" autocomplete="off" disabled />
          </el-form-item>
          <el-form-item label="楼盘名称" :label-width="formLabelWidth">
              <el-input v-model="store.state.homeview.editForm.title" autocomplete="off" />
          </el-form-item>
          <el-form-item label="房源类型" :label-width="formLabelWidth">
              <el-input v-model="store.state.homeview.editForm.type" autocomplete="off" />
          </el-form-item>
          <el-form-item label="门牌号" :label-width="formLabelWidth">
              <el-input v-model="store.state.homeview.editForm.num" autocomplete="off" />
          </el-form-item>
          <el-form-item label="房源户型" :label-width="formLabelWidth">
              <el-input v-model="store.state.homeview.editForm.hometype" autocomplete="off" />
          </el-form-item>
          <el-form-item label="户主" :label-width="formLabelWidth">
              <el-input v-model="store.state.homeview.editForm.name" autocomplete="off" />
          </el-form-item>
      </el-form>
      <template #footer>
          <span class="dialog-footer">
              <el-button @click="handlecancel">取消</el-button>
              <el-button type="primary" @click="handelsubmit">确定</el-button>
          </span>
      </template>
  </el-dialog>
</template>
<script setup lang="ts">
    import { reactive, ref } from 'vue'
    import { useStore } from "vuex";
    import link from '../api/link.js'

    const store = useStore()
    const dialogTableVisible = ref(false)
    const dialogFormVisible = ref(false)
    const formLabelWidth = '140px'
    const form = reactive({
        name: '',
        region: '',
        date1: '',
        date2: '',
        delivery: false,
        type: [],
        resource: '',
        desc: '',
    })
    // 修改
    const handelsubmit = () => {
      link(`/userlist/${store.state.homeview.editForm.id}`, 'put', store.state.homeview.editForm).then(res => {
            if (res.status === 200) {
                ElMessage({
                    message: '修改成功！',
                })
                emit('getList')
            } else {
                ElMessage({
                    message: '修改失败！',
                })
            }
            store.commit('changeDialog')
        })
    }
    // 取消修改
    const handlecancel = () => {
      store.commit('changeDialog')
      ElMessage({
          message: '已取消！',
      })
    }
    </script>
<style scoped>
    .el-button--text {
        margin-right: 15px;
    }
    .el-select {
        width: 300px;
    }
    /* .el-input {
        width: 300px;
    } */
    .dialog-footer button:first-child {
        margin-right: 10px;
    }
</style>